/// 错误常量
class ErrorConstants {
  ErrorConstants._();
  
  /// 通用错误消息
  static final generic = _GenericErrorMessages();
  
  /// 认证相关错误消息
  static final auth = _AuthErrorMessages();
  
  /// 网络相关错误消息
  static final network = _NetworkErrorMessages();
  
  /// 设备相关错误消息
  static final device = _DeviceErrorMessages();
  
  /// 验证相关错误消息
  static final validation = _ValidationErrorMessages();

  // 通用错误
  static const String unknownError = 'error.unknown';
  static const String connectionError = 'error.connection';
  static const String timeoutError = 'error.timeout';
  static const String unexpectedError = 'error.unexpected';
  
  // 认证错误
  static const String invalidCredentials = 'error.auth.invalid_credentials';
  static const String userNotFound = 'error.auth.user_not_found';
  static const String emailAlreadyExists = 'error.auth.email_exists';
  static const String weakPassword = 'error.auth.weak_password';
  static const String unauthorized = 'error.auth.unauthorized';
  static const String tokenExpired = 'error.auth.token_expired';
  
  // 服务器错误
  static const String serverError = 'error.server';
  static const String serviceUnavailable = 'error.service_unavailable';
  static const String badRequest = 'error.bad_request';
  static const String notFound = 'error.not_found';
  static const String forbidden = 'error.forbidden';
  
  // 表单错误
  static const String requiredField = 'error.form.required';
  static const String invalidEmail = 'error.form.invalid_email';
  static const String invalidPassword = 'error.form.invalid_password';
  static const String passwordMismatch = 'error.form.password_mismatch';
  static const String invalidPhone = 'error.form.invalid_phone';
  
  // 设备错误
  static const String deviceNotFound = 'error.device.not_found';
  static const String deviceOffline = 'error.device.offline';
  static const String deviceBusy = 'error.device.busy';
  static const String deviceError = 'error.device.error';
  
  // 用户错误
  static const String userDisabled = 'error.user.disabled';
  static const String userInactive = 'error.user.inactive';
  static const String userLocked = 'error.user.locked';
}

/// 通用错误消息
class _GenericErrorMessages {
  final String unknown = '发生未知错误，请稍后重试';
  final String serverError = '服务器错误，请稍后重试';
  final String notFound = '请求的资源不存在';
  final String timeout = '请求超时，请稍后重试';
  final String cancelled = '操作已取消';
  final String unsupportedOperation = '不支持的操作';
  final String internalError = '内部错误，请联系管理员';
  final String formatError = '数据格式错误';
  final String invalidData = '无效的数据';
  final String unexpectedError = '发生意外错误，请重试';
}

/// 认证相关错误消息
class _AuthErrorMessages {
  final String invalidCredentials = '用户名或密码错误';
  final String accountLocked = '账号已锁定，请联系管理员';
  final String accountDisabled = '账号已禁用，请联系管理员';
  final String sessionExpired = '会话已过期，请重新登录';
  final String tokenExpired = '登录凭证已过期，请重新登录';
  final String unauthorized = '未授权操作，请重新登录';
  final String accountNotFound = '账号不存在';
  final String invalidToken = '无效的登录凭证';
  final String emailAlreadyExists = '邮箱已被注册';
  final String usernameAlreadyExists = '用户名已被占用';
  final String weakPassword = '密码强度不足';
  final String tooManyAttempts = '登录尝试次数过多，请稍后再试';
  final String loginFailed = '登录失败，请稍后重试';
  final String registrationFailed = '注册失败，请稍后重试';
  final String resetPasswordFailed = '重置密码失败，请稍后重试';
  final String verificationFailed = '验证失败，请重试';
}

/// 网络相关错误消息
class _NetworkErrorMessages {
  final String noConnection = '无网络连接，请检查网络设置';
  final String connectionFailed = '连接服务器失败，请检查网络';
  final String connectionLost = '网络连接已断开';
  final String timeout = '网络请求超时';
  final String serverNotReachable = '无法连接到服务器';
  final String badResponse = '服务器响应异常';
  final String sslError = 'SSL证书验证失败';
  final String dnsError = 'DNS解析失败';
  final String proxyError = '代理服务器连接失败';
}

/// 设备相关错误消息
class _DeviceErrorMessages {
  final String deviceNotFound = '设备不存在';
  final String deviceOffline = '设备离线，请检查设备连接状态';
  final String deviceBusy = '设备忙，请稍后再试';
  final String deviceError = '设备发生错误';
  final String deviceConnectionFailed = '设备连接失败';
  final String deviceDisconnected = '设备已断开连接';
  final String deviceTimeout = '设备响应超时';
  final String deviceLimitExceeded = '已达到设备数量上限';
  final String deviceNotResponding = '设备无响应';
  final String deviceNotSupported = '不支持该设备类型';
  final String deviceInvalidOperation = '设备不支持该操作';
  final String deviceMalfunction = '设备故障，请检查设备';
  final String deviceDataError = '设备数据异常';
  final String deviceAuthFailed = '设备认证失败';
  final String deviceAlreadyBound = '设备已被绑定';
}

/// 验证相关错误消息
class _ValidationErrorMessages {
  final String required = '该字段不能为空';
  final String invalidEmail = '请输入有效的邮箱地址';
  final String invalidPhone = '请输入有效的手机号码';
  final String invalidPassword = '密码格式不正确';
  final String passwordMismatch = '两次输入的密码不一致';
  final String invalidUsername = '用户名只能包含字母、数字和下划线';
  final String invalidUrl = '请输入有效的URL';
  final String invalidDate = '请输入有效的日期';
  final String invalidTime = '请输入有效的时间';
  final String invalidNumber = '请输入有效的数字';
  final String invalidLength = '输入长度不符合要求';
  final String outOfRange = '输入值超出允许范围';
  final String invalidFormat = '格式不正确';
  final String invalidCode = '验证码不正确';
} 